export const StatusTypes = [{
		name: 'ops.status-1',
		stepName: 'ops.step.name-1',
		value: 1,
		color: 'rgba(255, 162, 0, 1)',
		bgColor: 'rgba(255, 162, 0, 0.16)'
	},
	{
		name: 'ops.status-2',
		stepName: 'ops.step.name-2',
		value: 2,
		color: 'rgba(100, 183, 246, 1)',
		bgColor: 'rgba(100, 183, 246, 0.16)'
	},
	{
		name: 'ops.status-3',
		stepName: 'ops.step.name-3',
		value: 3,
		color: 'rgba(154, 115, 255, 1)',
		bgColor: 'rgba(154, 115, 255, 0.16)'
	},
	{
		name: 'ops.status-4',
		stepName: 'ops.step.name-4',
		value: 4,
		color: 'rgba(88, 210, 130, 1)',
		bgColor: 'rgba(88, 210, 130, 0.16)'
	},
	{
		name: 'ops.status-5',
		stepName: 'ops.step.name-5',
		value: 5,
		color: 'rgba(132, 132, 132, 1)',
		bgColor: 'rgba(132, 132, 132, 0.16)'
	}
]

export const StatusTypesMap = {
	[StatusTypes[0].value]: StatusTypes[0],
	[StatusTypes[1].value]: StatusTypes[1],
	[StatusTypes[2].value]: StatusTypes[2],
	[StatusTypes[3].value]: StatusTypes[3],
	[StatusTypes[4].value]: StatusTypes[4]
}

export const StatusFilterTabs = [{
		name: 'ops.status-0',
		value: -1
	},
	StatusTypes[0],
	StatusTypes[1],
	StatusTypes[2],
	StatusTypes[3],
	StatusTypes[4]
]

// 封装创建步骤对象的函数
const createStep = (statusValue, temp) => {
	const status = StatusTypesMap[statusValue];
	return {
		title: status.stepName,
		time: temp[statusValue]?.createTime,
		operateUser: temp[statusValue]?.operateUser
	};
};

export const parseSteps = (status, records = []) => {
	const temp = {};
	records.forEach(item => {
		temp[item.status] = item;
	});

	const steps = [createStep(1, temp)];

	if (status === 5) {
		steps.push(createStep(5, temp));
	} else {
		[2, 3, 4].forEach(statusValue => {
			steps.push(createStep(statusValue, temp));
		});
	}

	return steps;
};